﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Criterion;
using ZDSoft.TES.Entity.SystemEntity;
using ZDSoft.TES.Service.SystemService;
using ZDSoft.TES.Manager.SystemManager;


namespace ZDSoft.TES.Component.SystemComponent
{
    public class UserComponent : ComponentBase<User, UserManager>, IUserService
    {
        UserManager userManager = (UserManager)typeof(UserManager).GetConstructor(Type.EmptyTypes).Invoke(null);
        RoleManager roleManager = (RoleManager)typeof(RoleManager).GetConstructor(Type.EmptyTypes).Invoke(null);
        OrganizationManager organizationManager = (OrganizationManager)typeof(OrganizationManager).GetConstructor(Type.EmptyTypes).Invoke(null);
        public User Login(string account, string password)
        {
            IList<ICriterion> conditions = new List<ICriterion>();
            conditions.Add(Expression.Eq("IsActive", true));
            conditions.Add(Expression.Eq("Account", account));
            conditions.Add(Expression.Eq("Password", password));
            IList<User> list = Find(conditions);
            if (list == null || list.Count == 0)
            {
                return null;
            }
            else
            {
                return list[0];
            }
        }


    }
}
